﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Nhom14_HTTTHD_BuyMe
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["login"] == "1")
            {
                float money = 0;
                using (websitebrokenEntities context = new websitebrokenEntities())
                {
                    int id_Acc = Convert.ToInt32(Session["user"]);
                    account obj = new account();
                    var kq = from s in context.accounts
                             where s.id == id_Acc
                             select s;
                    obj = kq.First();
                    money = (float)obj.credit;
                }
                Label1.Text = "<li class=\"first\">Hi, <b class=\"title\">" + Session["name"].ToString() + "</b></li><li>Credit: " + money.ToString()+ "</li>";
            }
            else
            {
                Label1.Text = "<li class=\"first\"><a href=\"login.aspx\">Login</a></li><li><b class=\"title\"><a href=\"register.aspx\">register</a></b><li>";
                LinkButton1.Visible = false;
            }
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Session["login"] = 0;
        }
    }
}
